package com.dcd.controller;

import com.dcd.pojo.Car_series;
import com.dcd.service.Car_seriesService;
import org.apache.solr.client.solrj.SolrServerException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.io.IOException;
import java.util.List;
import java.util.Map;


@RestController
public class Car_seriesController {

    @Autowired
    private Car_seriesService car_seriesService;

    /**
     * 查询历史浏览车系
     *
     * @param car_series_ids 历史浏览车系id数组
     * @return
     */
    @RequestMapping("/select_history_browsing_car_series")
    public List<Car_series> select_history_browsing_car_series(@RequestParam String[] car_series_ids) {
        return car_seriesService.select_history_browsing_car_series(car_series_ids);
    }

    /**
     * 查询指定用户收藏车系
     *
     * @param user_id 用户id
     * @return
     */
    @RequestMapping("/select_my_follow_car_series")
    private List<Car_series> select_my_follow_car_series(@RequestParam int user_id) {
        return car_seriesService.select_my_follow_car_series(user_id);
    }

    /**
     * 选车
     *
     * @param conditions 多个条件
     * @return
     */
    @RequestMapping("/vehicle_selection_by_conditions")
    public Map<String, Object> vehicle_selection_by_conditions(@RequestParam Map<String, String> conditions) {
        return car_seriesService.vehicle_selection_by_conditions(conditions);
    }

    /**
     * 查询指定条件车图
     *
     * @param conditions 多个条件
     * @return
     */
    @RequestMapping("/select_all_series_images_by_conditions")
    public Map<String, Object> select_all_series_images_by_conditions(@RequestParam Map<String, String> conditions) {
        return car_seriesService.select_all_series_images_by_conditions(conditions);
    }

    /**
     * 查询指定车系信息
     *
     * @param car_series_id 车系id
     * @return
     */
    @RequestMapping("/select_car_series_by_id")
    public Car_series select_car_series_by_id(@RequestParam int car_series_id) {
        return car_seriesService.select_car_series_by_id(car_series_id);
    }

    /**
     * 查询首页头部车系
     *
     * @param different_countries 根据国别查询
     * @param price               //价格
     * @return 返回轿车车系名称 返回Suv车系名称 返回其他车系名称
     */
    @RequestMapping("/select_index_heand_levei_series")
    public Map<String, Object> select_index_heand_levei_series(@RequestParam Integer different_countries, @RequestParam String price) {
        return car_seriesService.select_index_heand_levei_series(different_countries, price);
    }

    /**
     * 查询同级车排行--5辆
     *
     * @param conditions_type            条件类型（销量/热门度/懂车分）
     * @param car_series_id              车系id
     * @param car_series_car_level_fk_id 该车系级别id
     * @return
     */
    @RequestMapping("/select_same_level_ranking")
    public List<Car_series> select_same_level_ranking(@RequestParam String conditions_type, @RequestParam int car_series_id, @RequestParam int car_series_car_level_fk_id) {
        return car_seriesService.select_same_level_ranking(conditions_type, car_series_id, car_series_car_level_fk_id);
    }

    /**
     * 查询首页新车
     *
     * @return 返回 名称 时间 最低价格 最高价格 图片 资讯id 资讯标题
     */
    @RequestMapping("/select_index_new_series")
    public List<Car_series> select_index_new_series() {
        return car_seriesService.select_index_new_series();
    }

    /**
     * 查询车系名称 品牌名称
     * @param car_series_id 车系id
     * @return
     */
    @RequestMapping("/select_series_id_brand")
    public Car_series select_series_id_brand(@RequestParam Integer car_series_id) {
        return car_seriesService.select_series_id_brand(car_series_id);
    }

    /**
     *  排行榜分页查询所有(根据销量排行)并加入条件
     * @param pageRankingIndex   当前页
     * @param brand_id  品牌id
     * @param car_level_id   等级id
     * @param newtime   销售日期(202202)
     * @param min_price  最低金额
     * @param max_price  最高金额 区间
     * @return map返回数据
     */
    @RequestMapping("/select_sales_all_series")
    public Map<String, Object> select_sales_all_series(@RequestParam Integer pageRankingIndex,@RequestParam Integer brand_id,@RequestParam Integer car_level_id,@RequestParam Integer newtime,@RequestParam Integer min_price,@RequestParam Integer max_price) {
        return car_seriesService.select_sales_all_series(pageRankingIndex,brand_id,car_level_id,newtime,min_price,max_price);
    }

    /**
     * 查询车系视频推荐排行榜
     * @return
     */
    @RequestMapping("/select_series_video_recommend_ranking")
    List<Car_series> select_series_video_recommend_ranking(){
       return  car_seriesService.select_series_video_recommend_ranking();
    };
    /**
     * 热销榜(排行榜)
     * @return
     */
    @RequestMapping("/select_hot_ranking")
    public List<Car_series> select_hot_ranking(){
        return car_seriesService.select_hot_ranking();
    }

    /**
     * 降价榜(排行榜)
     * @return
     */
    @RequestMapping("/select_cut_price_ranking")
    public List<Car_series> select_cut_price_ranking(){
        return car_seriesService.select_cut_price_ranking();
    }


    /**
     * 查询指定节目下所有视频的所有车系
     *
     * @param program_id
     * @return
     */
    @RequestMapping("/select_appoint_program_all_car_series")
    public List<Car_series> select_appoint_program_all_car_series(@RequestParam int program_id) {
        return car_seriesService.select_appoint_program_all_car_series(program_id);
    }

    /**
     * 搜索查询车系
     *
     * @param solr_content 搜索文本内容
     * @param page_index   当前页数
     * @return
     */
    @RequestMapping("/select_car_series_by_solr")
    public Map<String, Object> select_car_series_by_solr(@RequestParam String solr_content, @RequestParam int page_index) throws IOException, SolrServerException {
        return car_seriesService.select_car_series_by_solr(solr_content, page_index);
    }

    /**
     * 根据热门度查询所有车系名称在搜索文本框中显示
     *
     * @return
     */
    @RequestMapping("/select_all_car_series_name")
    public List<Car_series> select_all_car_series_name() {
        return car_seriesService.select_all_car_series_name();
    }


    /**
     * 查询相关车系
     * 返回车系id  平均分  产商指导价  最高降幅  品牌名称 品牌图片
     * @param car_series_id
     * @return
     */
    @RequestMapping("/select_interrelated_series")
    public List<Car_series> select_interrelated_series(@RequestParam int car_series_id) {

        return car_seriesService.select_interrelated_series(car_series_id);
    }

}
